import log from '@dfeidao/atom-nodejs/logger/log';
import { IncomingHttpHeaders } from 'http';
import query from "@dfeidao/atom-nodejs/db/query";
import count from '@dfeidao/atom-nodejs/db/count';
import { systemid, productid } from '../../atom/config';
interface Message {
	plan_list_no: string[],
	// cookie: {
	// 	uk: string;
	// 	[key: string]: string
	// };
	// urls: {
	// 	base: string;
	// 	origin: string;
	// 	url: string;
	// };
	// query: {};
	// params: {};
	// headers: {};
	// captcha: string;
}

interface IWebResult {
	data: unknown;
	cookie?: {
		[name: string]: string;
	} | null;
	content_type?: string;
	headers?: {
		[key: string]: string[];
	};
	attachment?: string;
	redirect?: string;
	status_code?: number;
}
// 表名	planning_project				
// 标题	计划项目				
// 字段名称	字段标题	字段类型	字段长度	是否为空	是否主键
// _id	id	string	50	ⅹ	√
// plan_item_no	计划项目编号	string	50	√	ⅹ
// plan_list_no	计划清单编号	string	50	√	ⅹ
// post_no	岗位编号	string	30	√	ⅹ
// post_name	岗位名称	string	50	√	ⅹ
// plan_item_name	计划项目名称	string	200	√	ⅹ
// plan_item_depict	计划项目描述	string	500	√	ⅹ
// productid	产品ID	string	50	√	ⅹ



export default async function atom(message: Message, action_id: string, session_id: string, headers: IncomingHttpHeaders): Promise<IWebResult> {
	log('Service begin path:e:\王举\学习文件\飞道工作文件\测试项目\kh\src\wangju\zj-000007\s001,action_id:' + action_id);

	const { prepare, exec } = query(action_id, session_id, systemid);
	prepare('planning_project', ['plan_item_no', 'plan_list_no', 'post_no', 'post_name', 'plan_item_name'], { productid, plan_list_no: { $in: message.plan_list_no } }, 200, 1, [], []);
	const [res] = await exec<{ plan_item_no: string }>();
	log('Service end path:e:\王举\学习文件\飞道工作文件\测试项目\kh\src\wangju\zj-000007\s001,action_id:' + action_id);
	return {
		data: { res }
	};
}
